Bingo, Computer Graphics & Game Developer

Direction of refraction

Demo

已知平面法向量N\vec{N}, 入射向量L\vec{L}, 代求向量T\vec{T}, 入射夹角θ1\theta_1, 折射角θ2\theta_2,现求T\vec{T}. N\vec{N}, L\vec{L}T\vec{T}均为方向向量.

L\vec{L}T\vec{T}分解到NN和切平面上,分量记为l1,l2,t1,t2l_1, l_2, t_1, t_2.

L=l1+l2L = l_1 + l_2

l2=N.cosθ1l2 = -N \ldotp cos\theta_1

可得

l1=Ll2=L+N.cosθ1l_1 = L - l_2 = L + N \ldotp cos\theta_1

这里t1t_1l1l_1方向一致, 令sinθ1sinθ2=η=n2n1\frac{sin\theta_1}{sin\theta_2} = \eta = \frac{n_2}{n_1}(菲涅尔公式)

t1=l1sinθ2sinθ1=l11ηt_1 = l_1 \frac{sin\theta_2}{sin\theta_1} = l_1 \frac{1}{\eta}

同理推出

T=t1+t2T = t_1 + t_2

t2=N.cosθ2t2 = -N \ldotp cos\theta_2

可得

T=l11ηNcosθ2=Ll2=1η(L+N.cosθ1)Ncosθ2=1ηL+N.(1ηcosθ1cosθ2)\begin{array}{l}
T & = & l_1 \frac{1}{\eta} - N cos\theta_2 \\
& = & L - l_2 \\
& = & \frac{1}{\eta}(L + N \ldotp cos\theta_1) - N * cos\theta_2 \\
& = & \frac{1}{\eta}L + N \ldotp (\frac{1}{\eta}cos\theta_1 - cos\theta_2)
\end{array}